<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>GrPPI: farm_pattern.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.svg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">GrPPI
   &#160;<span id="projectnumber">1.0</span>
   </div>
   <div id="projectbrief">Generic and Reusable Parallel Pattern Interface</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_0966d06610f72609fd9aa4979c2b5a92.html">common</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">farm_pattern.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="farm__pattern_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * Copyright 2018 Universidad Carlos III de Madrid</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * </span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * you may not use this file except in compliance with the License.</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * You may obtain a copy of the License at</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> * </span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> *     http://www.apache.org/licenses/LICENSE-2.0</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * </span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * Unless required by applicable law or agreed to in writing, software</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> * See the License for the specific language governing permissions and</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * limitations under the License.</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#ifndef GRPPI_COMMON_FARM_PATTERN_H</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#define GRPPI_COMMON_FARM_PATTERN_H</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160; </div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="preprocessor">#include &lt;type_traits&gt;</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160; </div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacegrppi.html">grppi</a> {</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Transformer&gt;</div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="classgrppi_1_1farm__t.html">   29</a></span>&#160;<span class="keyword">class </span><a class="code" href="classgrppi_1_1farm__t.html">farm_t</a> {</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160; </div>
<div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="classgrppi_1_1farm__t.html#a4ad17400d1d798b3ff157ea8e695db88">   32</a></span>&#160;  <span class="keyword">using</span> <a class="code" href="classgrppi_1_1farm__t.html#a4ad17400d1d798b3ff157ea8e695db88">transformer_type</a> = Transformer;</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160; </div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="classgrppi_1_1farm__t.html#ac4d1c4eb9c1777eedef322b8fd624fa2">   39</a></span>&#160;  <a class="code" href="classgrppi_1_1farm__t.html#ac4d1c4eb9c1777eedef322b8fd624fa2">farm_t</a>(<span class="keywordtype">int</span> n, Transformer &amp;&amp; t) noexcept :</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    cardinality_{n}, transformer_{t}</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;  {}</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160; </div>
<div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="classgrppi_1_1farm__t.html#a07679d9df7a3ab0b1fe90c2d0a8855dd">   47</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classgrppi_1_1farm__t.html#a07679d9df7a3ab0b1fe90c2d0a8855dd">cardinality</a>() const noexcept {</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <span class="keywordflow">return</span> cardinality_;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;  }</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160; </div>
<div class="line"><a name="l00055"></a><span class="lineno"><a class="line" href="classgrppi_1_1farm__t.html#ae18b12445e1390bd7fb1cd8e29ec4d00">   55</a></span>&#160;  Transformer &amp; <a class="code" href="classgrppi_1_1farm__t.html#ae18b12445e1390bd7fb1cd8e29ec4d00">transformer</a>(){</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="keywordflow">return</span> transformer_;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;  }</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  <span class="keyword">template</span> &lt;<span class="keyword">typename</span> I&gt;</div>
<div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="classgrppi_1_1farm__t.html#a075364347274e0ff82cad5ae485522ea">   62</a></span>&#160;  <span class="keyword">auto</span> <a class="code" href="classgrppi_1_1farm__t.html#a075364347274e0ff82cad5ae485522ea">operator()</a>(I &amp;&amp; item)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="keywordflow">return</span> transformer_(std::forward&lt;I&gt;(item));</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;  }</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160; </div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;  <span class="keywordtype">int</span> cardinality_;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;  Transformer transformer_;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;};</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160; </div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="keyword">namespace </span>internal {</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160; </div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</div>
<div class="line"><a name="l00074"></a><span class="lineno"><a class="line" href="structgrppi_1_1internal_1_1is__farm.html">   74</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structgrppi_1_1internal_1_1is__farm.html">is_farm</a> : std::false_type {};</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160; </div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;<span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</div>
<div class="line"><a name="l00077"></a><span class="lineno"><a class="line" href="structgrppi_1_1internal_1_1is__farm_3_01farm__t_3_01_t_01_4_01_4.html">   77</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structgrppi_1_1internal_1_1is__farm.html">is_farm</a>&lt;<a class="code" href="classgrppi_1_1farm__t.html">farm_t</a>&lt;T&gt;&gt; : std::true_type {};</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160; </div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;} <span class="comment">// namespace internal</span></div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160; </div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div>
<div class="line"><a name="l00082"></a><span class="lineno"><a class="line" href="namespacegrppi.html#a5b5a7cc855d5952bb3cafe51a54ba458">   82</a></span>&#160;<span class="keyword">static</span> constexpr <span class="keywordtype">bool</span> <a class="code" href="namespacegrppi.html#a5b5a7cc855d5952bb3cafe51a54ba458">is_farm</a> = <a class="code" href="structgrppi_1_1internal_1_1is__farm.html">internal::is_farm&lt;std::decay_t&lt;T&gt;</a>&gt;();</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160; </div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div>
<div class="line"><a name="l00085"></a><span class="lineno"><a class="line" href="namespacegrppi.html#a43af869a5c133642518967b6284525af">   85</a></span>&#160;<span class="keyword">using</span> <a class="code" href="namespacegrppi.html#a43af869a5c133642518967b6284525af">requires_farm</a> = <span class="keyword">typename</span> std::enable_if_t&lt;is_farm&lt;T&gt;, <span class="keywordtype">int</span>&gt;;</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160; </div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;}</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160; </div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="aclassgrppi_1_1farm__t_html"><div class="ttname"><a href="classgrppi_1_1farm__t.html">grppi::farm_t</a></div><div class="ttdoc">Representation of farm pattern. Represents a farm of n replicas from a transformer.</div><div class="ttdef"><b>Definition:</b> farm_pattern.h:29</div></div>
<div class="ttc" id="aclassgrppi_1_1farm__t_html_a075364347274e0ff82cad5ae485522ea"><div class="ttname"><a href="classgrppi_1_1farm__t.html#a075364347274e0ff82cad5ae485522ea">grppi::farm_t::operator()</a></div><div class="ttdeci">auto operator()(I &amp;&amp;item) const</div><div class="ttdoc">Invokes the transformer of the farm over a data item.</div><div class="ttdef"><b>Definition:</b> farm_pattern.h:62</div></div>
<div class="ttc" id="aclassgrppi_1_1farm__t_html_a07679d9df7a3ab0b1fe90c2d0a8855dd"><div class="ttname"><a href="classgrppi_1_1farm__t.html#a07679d9df7a3ab0b1fe90c2d0a8855dd">grppi::farm_t::cardinality</a></div><div class="ttdeci">int cardinality() const noexcept</div><div class="ttdoc">Farm's cardinality or number of replicas.</div><div class="ttdef"><b>Definition:</b> farm_pattern.h:47</div></div>
<div class="ttc" id="aclassgrppi_1_1farm__t_html_a4ad17400d1d798b3ff157ea8e695db88"><div class="ttname"><a href="classgrppi_1_1farm__t.html#a4ad17400d1d798b3ff157ea8e695db88">grppi::farm_t::transformer_type</a></div><div class="ttdeci">Transformer transformer_type</div><div class="ttdef"><b>Definition:</b> farm_pattern.h:32</div></div>
<div class="ttc" id="aclassgrppi_1_1farm__t_html_ac4d1c4eb9c1777eedef322b8fd624fa2"><div class="ttname"><a href="classgrppi_1_1farm__t.html#ac4d1c4eb9c1777eedef322b8fd624fa2">grppi::farm_t::farm_t</a></div><div class="ttdeci">farm_t(int n, Transformer &amp;&amp;t) noexcept</div><div class="ttdoc">Constructs a farm with a cardinality and a transformer.</div><div class="ttdef"><b>Definition:</b> farm_pattern.h:39</div></div>
<div class="ttc" id="aclassgrppi_1_1farm__t_html_ae18b12445e1390bd7fb1cd8e29ec4d00"><div class="ttname"><a href="classgrppi_1_1farm__t.html#ae18b12445e1390bd7fb1cd8e29ec4d00">grppi::farm_t::transformer</a></div><div class="ttdeci">Transformer &amp; transformer()</div><div class="ttdoc">Return the transformer function stored in the farm pattern.</div><div class="ttdef"><b>Definition:</b> farm_pattern.h:55</div></div>
<div class="ttc" id="anamespacegrppi_html"><div class="ttname"><a href="namespacegrppi.html">grppi</a></div><div class="ttdef"><b>Definition:</b> callable_traits.h:21</div></div>
<div class="ttc" id="anamespacegrppi_html_a43af869a5c133642518967b6284525af"><div class="ttname"><a href="namespacegrppi.html#a43af869a5c133642518967b6284525af">grppi::requires_farm</a></div><div class="ttdeci">typename std::enable_if_t&lt; is_farm&lt; T &gt;, int &gt; requires_farm</div><div class="ttdef"><b>Definition:</b> farm_pattern.h:85</div></div>
<div class="ttc" id="anamespacegrppi_html_a5b5a7cc855d5952bb3cafe51a54ba458"><div class="ttname"><a href="namespacegrppi.html#a5b5a7cc855d5952bb3cafe51a54ba458">grppi::is_farm</a></div><div class="ttdeci">static constexpr bool is_farm</div><div class="ttdef"><b>Definition:</b> farm_pattern.h:82</div></div>
<div class="ttc" id="astructgrppi_1_1internal_1_1is__farm_html"><div class="ttname"><a href="structgrppi_1_1internal_1_1is__farm.html">grppi::internal::is_farm</a></div><div class="ttdef"><b>Definition:</b> farm_pattern.h:74</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
